home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Snippets / Stuart's Tech Notes / FatKit / FatKit.c < prev    next >
C/C++ Source or Header  |  1995-09-20  |  3KB  |  112 lines

  1. static void show_alert(void);
  2.  
  3. void main(void)
  4.     {
  5. #if __option(a4_globals)
  6.     asm {                    ; Segment loader info
  7.         dc.w    0            ; This CODE resource's offset in the jump table
  8.         dc.w    1            ; Number of entries this CODE resource has in the jump table
  9.         jsr        @1            ; push known address onto the stack
  10.     @1    move.l    (sp)+, a4    ; pop it into a4
  11.         lea        -8(a4), a4    ; adjust it back to base address of code segment
  12.         MaxApplZone
  13.         pea        -4(a5)
  14.         InitGraf
  15.         }
  16. #else
  17.     MaxApplZone();
  18.     InitGraf(&qd.thePort);
  19. #endif
  20.     
  21.     InitFonts();
  22.     InitWindows();
  23.     InitMenus();
  24.     TEInit();
  25.     InitDialogs(NULL);
  26.     InitCursor();
  27.     FlushEvents(everyEvent,0);
  28.     ParamText(LMGetCurApName(), NULL, NULL, NULL);
  29.     show_alert();
  30.     }
  31.  
  32. static pascal void OutlineOK(DialogPtr dlg, short item)
  33.     {
  34.     short    di_type;
  35.     Handle    di_handle;
  36.     Rect    di_box;
  37.     PenSize(3,3);
  38.     GetDItem(dlg, 1, &di_type, &di_handle, &di_box);
  39.     InsetRect(&di_box,-4,-4);
  40.     FrameRoundRect(&di_box,16,16);
  41.     PenNormal();
  42.     }
  43.  
  44. static void set_OutlineOK(DialogPtr d, short item)
  45.     {
  46.     short    di_type;
  47.     Handle    di_handle;
  48.     Rect    di_box;
  49.     GetDItem(d, item, &di_type, &di_handle, &di_box);
  50.     SetDItem(d, item,  di_type, (Handle)OutlineOK, &di_box);
  51.     }
  52.  
  53. typedef struct
  54.     {
  55.     short count;
  56.     short item1_unknown1;
  57.     short item1_unknown2;
  58.     Rect  item1_DisplayRect;
  59.     char  item1_type;
  60.     char  item1_info[0x03];        // "OK" text
  61.     short item2_unknown1;
  62.     short item2_unknown2;
  63.     Rect  item2_DisplayRect;
  64.     char  item2_type;
  65.     char  item2_info[0x01];        // No data
  66.     short item3_unknown1;
  67.     short item3_unknown2;
  68.     Rect  item3_DisplayRect;
  69.     char  item3_type;
  70.     char  item3_info[0x03];        // Icon Resource ID (zero)
  71.     short item4_unknown1;
  72.     short item4_unknown2;
  73.     Rect  item4_DisplayRect;
  74.     char  item4_type;
  75.     char  item4_info[0xFF];        // Message Text (length must be odd for proper alignment!)
  76.     } DITL;
  77.  
  78. static const Rect wRect = { 0, 0, 100, 420 };
  79. static const DITL theDITL =
  80.     {
  81.     3,
  82.     0, 0, { 70,  16, 90,  76 }, 0x04, "\pOK",
  83.     0, 0, { 40,   0, 50,  10 }, 0x80, "\p",
  84.     0, 0, { 20,  30, 52,  62 }, 0xA0, "\p\0\0",
  85.     0, 0, { 10, 100, 90, 400 }, 0x88,
  86.     "\p^0 can only run on a Macintosh computer that has a PowerPC processor."
  87.     " This Macintosh computer has a 680x0 series processor, which cannot run"
  88.     " native PowerPC applications."
  89.     };
  90.  
  91. static void show_alert(void)
  92.     {
  93.     DialogRecord dStorage;
  94.     DialogPtr theDialog;
  95.     short itemHit;
  96.     BitMap *winbm;
  97.     short xmove, ymove;
  98.     Handle theDITLhand = NewHandle(sizeof(theDITL));
  99.     BlockMoveData(&theDITL, *theDITLhand, sizeof(theDITL));
  100.     theDialog = NewDialog(&dStorage, &wRect, NULL, FALSE,
  101.         dBoxProc, (WindowPtr)(-1), FALSE, 0, theDITLhand);
  102.     winbm = &theDialog->portBits;
  103.     if (winbm->rowBytes & 0x8000) winbm = *((BitMapHandle)(winbm->baseAddr));
  104.     xmove = (winbm->bounds.right  - winbm->bounds.left - wRect.right ) / 2;
  105.     ymove = (winbm->bounds.bottom - winbm->bounds.top  - wRect.bottom) / 4;
  106.     MoveWindow(theDialog, xmove, ymove, TRUE);
  107.     set_OutlineOK(theDialog, 2);
  108.     ShowWindow(theDialog);
  109.     ModalDialog(NULL, &itemHit);
  110.     CloseDialog(theDialog);
  111.     }
  112.